package model.action.suggest_deal_action;
import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
 
public class SendMail
{
              
        public static void main(String [] args)
        
        {    
        	String host = "mail.nhipcaugiaitri247.com";
            String from = "giaitri@nhipcaugiaitri27.com";
            String pass = "Admin-123";
            Properties props = System.getProperties();
            props.put("mail.smtp.host", host);
            props.put("mail.smtp.user", "giaitri");
            props.put("mail.smtp.password", pass);
            props.put("mail.smtp.port", "587");
            props.put("mail.smtp.auth", "true");
            
           // Recipient's email ID needs to be mentioned.
           String to = "duonghoaikhanh@gmail.com";


           // Get the default Session object.
           Session session = Session.getDefaultInstance(props,null);

           try{
              // Create a default MimeMessage object.
              MimeMessage message = new MimeMessage(session);

              // Set From: header field of the header.
              message.setFrom(new InternetAddress(from));

              // Set To: header field of the header.
              message.addRecipient(Message.RecipientType.TO,
                                       new InternetAddress(to));

              // Set Subject: header field
              message.setSubject("Concern Deal of consumer!");

              // Now set the actual message
              message.setText("Chào b?n!!! Ðây là m?t s? Deal mà các b?n quan tâm, Chúc các b?n mua hàng vui v? ^^");

              // Send message
              Transport transport = session.getTransport("smtp");
              transport.connect(host, "giaitri", pass);
              transport.sendMessage(message, message.getAllRecipients());
              transport.close();
              System.out.println("Sent message successfully....");
           }catch (MessagingException mex) {
              mex.printStackTrace();
           }
        }
}